[id].vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1>
  6. <!-- 商圈详情 -->
  7. <div class="topicInfoBox">
  8. <div class="inner">
  9. <!-- 详情头部 -->
  10. <div class="infoHead">
  11. <div class="left">
  12. <div class="userInfo left">
  13. <el-badge value="楼主" class="item" type="warning">
  14. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  15. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  16. </el-badge>
  17. <span>{{ dataInfo.author }}</span>
  18. </div>
  19. <div class="headContent left">
  20. <h2>{{ dataInfo.title }}</h2>
  21. <p v-show="dataInfo.group_name">
  22. 群聊:
  23. <span>{{ dataInfo.group_name }}</span>
  24. <button @click="joinGroup">加入群聊</button>
  25. </p>
  26. </div>
  27. </div>
  28. <div class="right">
  29. <div class="one">
  30. <span v-for="item in typeList" :key="index">
  31. <span v-if="dataInfo.type == item.value" class="one">{{item.label}}</span>
  32. </span>
  33. </div>
  34. <p>{{ dataInfo.updated_at }}</p>
  35. </div>
  36. </div>
  37. <!-- 详情页 文本+图片 -->
  38. <div class="infoContent" v-show="dataInfo.content">
  39. <div v-html="dataInfo.content"></div>
  40. </div>
  41. <div class="infoContent1" v-show="!dataInfo.content">
  42. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  43. <span>可以看看大家的互动哦~</span>
  44. </div>
  45. <!-- 详情页评论 -->
  46. <div class="comment">
  47. <h3>评论</h3>
  48. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  49. <div class="left">
  50. <img v-if='item.avatar' :src="item.avatar" alt="" >
  51. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  52. <span class="name">{{ item.author }} : </span>
  53. </div>
  54. <div class="center">
  55. <span class="context">{{ item.content }}</span>
  56. </div>
  57. <div class="right">
  58. <span class="time">{{ item.created_at }}</span>
  59. <!-- <span>回复</span> -->
  60. </div>
  61. </div>
  62. <div class="comment_empty" v-show="page_total == 0">
  63. <img src="../../public/topic/message_empty.png" alt="">
  64. <span>暂无评论</span>
  65. </div>
  66. </div>
  67. <!-- 分页 -->
  68. <div class="paginationBox" v-show="page_total != 0">
  69. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  70. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  71. </div>
  72. </div>
  73. </div>
  74. <div class="message">
  75. <div class="inner">
  76. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  77. <button class="btn" @click="addReply">确定</button>
  78. </div>
  79. </div>
  80. <!-- 页面底部 -->
  81. <HomeFoot1></HomeFoot1>
  82. </div>
  83. </template>
  84. <script setup>
  85. //1.引用模块 start ---------------------------------------->
  86. //使用ref和reactive动态变量
  87. import { ref, reactive, onMounted } from 'vue'
  88. import { useRoute } from 'vue-router';
  89. //使用官方ssr请求模块
  90. import { useNuxtApp, useFetch } from '#app'
  91. //使用element-plus组件
  92. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  93. // axios请求
  94. const nuxtApp = useNuxtApp();
  95. const axios = nuxtApp.$axios;
  96. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  97. //1.引用模块 end ---------------------------------------->
  98. // 定义响应式数据
  99. const seoData = ref({
  100. title: '商圈',
  101. description: '默认描述',
  102. keywords: '默认关键词',
  103. image: 'https://example.com/default-image.jpg'
  104. });
  105. // 在 onMounted 钩子中获取数据
  106. onMounted(()=>{
  107. seoData.value.title = '商圈';
  108. seoData.value.description = '默认描述';
  109. seoData.value.keywords = '默认关键词';
  110. })
  111. //2.页面数据 start ---------------------------------------->
  112. const dataInfo = ref({})
  113. const groupId = useState("groupId", () => '')
  114. const replyList = useState("replyList", () => []) //评论列表
  115. //分页
  116. const page = ref(1)
  117. const pageSize = ref(5)
  118. let page_total = ref(0)
  119. const content = ref('')
  120. //2.页面数据 end ---------------------------------------->
  121. //3.获取商圈详情 start ---------------------------------------->
  122. const route = useRoute();
  123. const id = route.params.id; // 获取传递的 id 参数
  124. //页码发生改变
  125. const changePage = (val) => {
  126. console.log(val);
  127. page.value = val
  128. getTopicReply()
  129. }
  130. // 商圈信息
  131. const getTopicInfo = () => {
  132. let data = new FormData()
  133. data.append('id', id)
  134. axios.post('chat/getTopicInfo', data).then(res => {
  135. console.log('商圈信息', res);
  136. dataInfo.value = res.data
  137. groupId.value = res.data.group_id
  138. console.log(groupId.value);
  139. })
  140. }
  141. // 回复商圈 列表
  142. const getTopicReply = () => {
  143. let data = new FormData()
  144. data.append('id', id)
  145. data.append('page', page.value)
  146. data.append('page_size', pageSize.value)
  147. axios.post('chat/getTopicReply', data).then(res => {
  148. console.log('回复商圈列表 ', res);
  149. replyList.value = res.data.data
  150. // page_total.value = res.data.total
  151. page_total.value = res.data.total
  152. console.log("replyList", replyList);
  153. })
  154. }
  155. //5.获取分类和状态 start ---------------------------------------->
  156. const listData = useState("listData", () => [])//商圈列表
  157. const typeList = useState("typeList", () => [])//商圈分类
  158. const topicType = () => {
  159. axios.post('/chat/topicType').then(response => {
  160. console.log(111222333)
  161. console.log(response.data);
  162. // console.log(1);
  163. typeList.value = response.data;
  164. })
  165. }
  166. const topicStatus = () => {
  167. axios.post('chat/topicStatus').then(response => {
  168. console.log(response);
  169. })
  170. }
  171. onMounted(() => {
  172. getTopicInfo(); //商圈信息
  173. getTopicReply(); //回复商圈列表
  174. topicType();
  175. topicStatus();
  176. })
  177. //加入群聊
  178. const joinGroup = () => {
  179. ElMessageBox.confirm(
  180. '加入群聊后,页面跳转至后台群聊页面',
  181. '是否加入群聊?',
  182. {
  183. confirmButtonText: '是',
  184. cancelButtonText: '否',
  185. center: true,
  186. }
  187. ).then(() => {
  188. console.log('groupId.value', groupId.value);
  189. let data = new FormData()
  190. data.append('group_id', groupId.value)
  191. axios.post('chat/joinGroup', data).then(res => {
  192. console.log('加入群聊 ', res);
  193. if (res.code == 0 && res.message !== '已加入群') {
  194. ElMessage.error(res.message)
  195. } else if (res.code == 0 && res.message == '已加入群') {
  196. ElMessage({
  197. message: res.message,
  198. type: 'success',
  199. })
  200. setTimeout(() => {
  201. window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  202. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  203. }, 1000)
  204. } else if (res.code == 200) {
  205. ElMessage({
  206. message: '加入成功',
  207. type: 'success',
  208. })
  209. setTimeout(() => {
  210. window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  211. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  212. }, 1000)
  213. }
  214. })
  215. }).catch(() => {
  216. ElMessage({
  217. type: 'error',
  218. message: '已取消',
  219. })
  220. })
  221. }
  222. // 回复商圈
  223. const addReply = () => {
  224. let data = new FormData()
  225. data.append('id', id)
  226. data.append('content', content.value)
  227. axios.post('chat/addReply', data).then(res => {
  228. console.log('回复商圈 ', res);
  229. if (res.code == 0) {
  230. ElMessage.error(res.message)
  231. getTopicReply();
  232. } else if (res.code == 200) {
  233. ElMessage({
  234. message: '回复成功',
  235. type: 'success',
  236. })
  237. content.value = ''
  238. getTopicReply();
  239. }
  240. })
  241. }
  242. //3.获取商圈详情 end ---------------------------------------->
  243. </script>
  244. <style lang="less" scoped>
  245. .topicInfoBox {
  246. .inner {
  247. width: 1200px;
  248. margin: 0 auto;
  249. //信息头部
  250. .infoHead {
  251. height: 200px;
  252. padding: 65px 0 60px 40px;
  253. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  254. box-sizing: border-box;
  255. >.left {
  256. .userInfo {
  257. margin-right: 90px;
  258. .item {
  259. margin-top: -5px;
  260. margin-right: -5px;
  261. :deep(.el-badge__content.is-fixed) {
  262. position: absolute;
  263. right: calc(1px + var(--el-badge-size) / 2);
  264. top: 0;
  265. transform: translateY(-31%) translateX(79%);
  266. z-index: var(--el-index-normal);
  267. }
  268. img {
  269. width: 66px;
  270. height: 66px;
  271. vertical-align: middle;
  272. border-radius: 50%;
  273. }
  274. }
  275. span {
  276. margin-left: 15px;
  277. font-family: Microsoft YaHei, Microsoft YaHei;
  278. font-weight: 400;
  279. font-size: 18px;
  280. color: #333333;
  281. }
  282. }
  283. .headContent {
  284. h2 {
  285. width: 750px;
  286. height: 56px;
  287. line-height: 28px;
  288. display: -webkit-box;
  289. -webkit-box-orient: vertical;
  290. -webkit-line-clamp: 2;
  291. overflow: hidden;
  292. text-overflow: ellipsis;
  293. word-break: break-all;
  294. font-family: Microsoft YaHei, Microsoft YaHei;
  295. font-weight: bold;
  296. font-size: 20px;
  297. color: #333333;
  298. margin-bottom: 26px;
  299. }
  300. >p {
  301. font-family: Microsoft YaHei, Microsoft YaHei;
  302. font-weight: 400;
  303. font-size: 16px;
  304. color: #333333;
  305. button {
  306. width: 86px;
  307. height: 32px;
  308. background-color: #028e21;
  309. color: #fff;
  310. border: none;
  311. margin-left: 100px;
  312. }
  313. }
  314. }
  315. }
  316. >.right {
  317. position: relative;
  318. div {
  319. position: absolute;
  320. right: 0;
  321. top: 0;
  322. width: 71px;
  323. height: 32px;
  324. line-height: 32px;
  325. text-align: center;
  326. background-color: #d9f0d6;
  327. margin-bottom: 29px;
  328. font-family: Microsoft YaHei, Microsoft YaHei;
  329. font-weight: 400;
  330. font-size: 16px;
  331. color: #33B023;
  332. }
  333. .one {
  334. color: #FFAA33;
  335. background-color: #fbebd5;
  336. }
  337. .two {
  338. color: #33B023;
  339. background-color: #d5ecd2;
  340. }
  341. .three {
  342. color: #666;
  343. background-color: #ebebeb;
  344. }
  345. p {
  346. width: 150px;
  347. text-align: right;
  348. position: absolute;
  349. top: 62px;
  350. right: 0;
  351. }
  352. }
  353. }
  354. // 有详情信息
  355. .infoContent {
  356. width:1196px;
  357. overflow: hidden;
  358. padding: 40px 46px;
  359. font-family: Microsoft YaHei, Microsoft YaHei;
  360. font-size: 20px;
  361. line-height: 40px;
  362. box-sizing: border-box;
  363. div{
  364. word-wrap: break-word; /* 强制长单词或 URL 换行 */
  365. overflow-wrap: break-word; /* 现代推荐用法,等同于 word-wrap */
  366. white-space: pre-wrap; /* 保留空白字符并允许自动换行 */
  367. word-break: break-all; /* 强制在任意字符处换行 */
  368. }
  369. }
  370. .leftBottom::v-deep p{
  371. width:1200px;
  372. white-space: pre-wrap;
  373. }
  374. //没有详情信息
  375. .comment_empty,
  376. .infoContent1 {
  377. height: 300px;
  378. line-height: 260px;
  379. text-align: center;
  380. img {
  381. width: 78px;
  382. height: 78px;
  383. vertical-align: -25px;
  384. vertical-align: middle;
  385. margin-right: 20px;
  386. }
  387. span {
  388. font-family: Microsoft YaHei, Microsoft YaHei;
  389. font-weight: bold;
  390. font-size: 26px;
  391. color: #CCCCCC;
  392. }
  393. }
  394. //评论
  395. .comment {
  396. h3 {
  397. height: 100px;
  398. padding-top: 30px;
  399. box-sizing: border-box;
  400. border-bottom: 1px solid #E1E1E1;
  401. font-family: Microsoft YaHei, Microsoft YaHei;
  402. font-weight: 400;
  403. font-size: 22px;
  404. color: #000000;
  405. }
  406. .commentList {
  407. // height: 112px;
  408. border: 1px solid #E1E1E1;
  409. background-color: #fafafa;
  410. margin-top: 20px;
  411. padding: 30px 30px;
  412. box-sizing: border-box;
  413. display: flex;
  414. align-items: flex-start;
  415. justify-content: space-between;
  416. .left {
  417. width:400px;
  418. margin-right: 40px;
  419. // overflow: hidden;
  420. display: flex;
  421. justify-content: space-between;
  422. img {
  423. // float: left;
  424. width: 52px;
  425. height: 52px;
  426. border-radius: 50%;
  427. vertical-align: middle;
  428. margin-right: 15px;
  429. }
  430. span{
  431. // float: left;
  432. height: 52px;
  433. line-height: 22px;
  434. padding-top: 10px;
  435. }
  436. .name {
  437. width: 100px;
  438. font-family: Microsoft YaHei, Microsoft YaHei;
  439. font-weight: 400;
  440. font-size: 16px;
  441. color: #333333;
  442. margin-right: 30px;
  443. width: 100px;
  444. white-space: nowrap;
  445. overflow: hidden;
  446. text-overflow: ellipsis;
  447. display: block;
  448. }
  449. }
  450. .center {
  451. .context {
  452. width: 700px;
  453. margin-right: 40px;
  454. display: -webkit-box;
  455. -webkit-box-orient: vertical;
  456. -webkit-line-clamp: 2;
  457. overflow: hidden;
  458. text-overflow: ellipsis;
  459. word-break: break-all;
  460. font-family: Microsoft YaHei, Microsoft YaHei;
  461. font-weight: bold;
  462. font-size: 16px;
  463. color: #333333;
  464. }
  465. }
  466. .right {
  467. .time {
  468. display: block;
  469. width: 200px;
  470. font-family: Microsoft YaHei, Microsoft YaHei;
  471. font-weight: 400;
  472. font-size: 16px;
  473. color: #999999;
  474. margin-right: 30px;
  475. }
  476. span {
  477. font-family: Microsoft YaHei, Microsoft YaHei;
  478. font-weight: 400;
  479. font-size: 16px;
  480. color: #333333;
  481. }
  482. }
  483. }
  484. // .comment_empty {
  485. // height: 200px;
  486. // line-height: 200px;
  487. // text-align: center;
  488. // img {
  489. // width: 78px;
  490. // height: 78px;
  491. // vertical-align: -25px;
  492. // margin-right: 20px;
  493. // }
  494. // span {
  495. // font-family: Microsoft YaHei, Microsoft YaHei;
  496. // font-weight: bold;
  497. // font-size: 26px;
  498. // color: #CCCCCC;
  499. // }
  500. // }
  501. }
  502. }
  503. }
  504. //评论回复
  505. .message {
  506. width: 1200px;
  507. margin: 0 auto;
  508. padding: 0px 25px;
  509. box-sizing: border-box;
  510. height: 145px;
  511. line-height: 145px;
  512. background-color: #ecf5ee;
  513. .inner {
  514. .messageInput {
  515. width: 1000px;
  516. height: 67px;
  517. outline: none;
  518. border: 1px solid #E1E1E1;
  519. background-color: #fafafa;
  520. font-family: Microsoft YaHei, Microsoft YaHei;
  521. font-weight: 400;
  522. font-size: 18px;
  523. color: #666;
  524. padding: 0 20px;
  525. box-sizing: border-box;
  526. }
  527. .btn {
  528. width: 115px;
  529. height: 40px;
  530. border: none;
  531. background-color: #028e21;
  532. color: #fff;
  533. border-radius: 6px;
  534. margin-left: 36px;
  535. font-family: Microsoft YaHei, Microsoft YaHei;
  536. font-weight: 400;
  537. font-size: 16px;
  538. }
  539. }
  540. }
  541. //分页
  542. .paginationBox {
  543. display: flex;
  544. justify-content: center;
  545. margin-top: 60px;
  546. margin-bottom: 90px;
  547. // 鼠标移入后字体颜色
  548. :deep(.el-pagination:hover) {
  549. color: #139609;
  550. }
  551. :deep(.el-pagination.is-background .btn-next),
  552. :deep(.el-pagination.is-background .btn-prev) {
  553. width: 70px;
  554. height: 34px;
  555. margin: 0px 10px;
  556. border-radius: 4px;
  557. }
  558. :deep(.el-pagination.is-background .el-pager li) {
  559. margin: 0px 10px;
  560. width: 38px;
  561. height: 34px;
  562. border-radius: 4px;
  563. }
  564. :deep(.el-pagination.is-background .btn-next.is-active),
  565. :deep(.el-pagination.is-background .btn-prev.is-active),
  566. :deep(.el-pagination.is-background .el-pager li.is-active) {
  567. background-color: #028e21;
  568. color: #fff;
  569. }
  570. }
  571. </style>